import {
  type RouteRecordRaw,
  createRouter,
  createWebHashHistory,
} from 'vue-router'
// import { setupGuard } from './guard'
import BasicLayout from '@/layouts/BasicLayout.vue'
import Page403 from '@/pages/Page403.vue'
import Page404 from '@/pages/Page404.vue'
import Page500 from '@/pages/Page500.vue'
import IndexPage from '@/pages/index.vue'
import PersonPage from '@/pages/person/index.vue'

const routes: RouteRecordRaw[] = [
  // {
  //   name: 'Login',
  //   path: '/login',
  //   component: Login,
  // },
  {
    name: 'Home',
    path: '/',
    component: BasicLayout,
    redirect: { name: 'PersonPage' },
    children: [
      {
        name: 'IndexPage',
        path: '/index',
        component: IndexPage,
      },
      {
        name: 'PersonPage',
        path: '/person',
        component: PersonPage,
      },
    ],
  },
  { path: '/page-403', name: 'Page403', component: Page403 },
  { path: '/page-500', name: 'Page500', component: Page500 },
  // 前面的路由都未匹配上，则会匹配到该路由
  { path: '/:pathMatch(.*)*', name: 'Page404', component: Page404 },
  // 将匹配以 `/user-` 开头的所有内容，并将其放在 `$route.params.afterUser` 下
  // { path: '/user-:afterUser(.*)', component: UserGeneric },
]
const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHashHistory(),
  routes, // `routes: routes` 的缩写
})

// setupGuard(router)

export default router
